package com.lzx.iteam.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.lzx.iteam.util.PreferenceUtil;

/**
 * Created by hfx on 14-12-14.
 * @author liukun
 */
public class BottomFrameLayout extends FrameLayout {
    Context mContext;
    public BottomFrameLayout(Context context){
        super(context);
    }

    public BottomFrameLayout(Context context, AttributeSet attrs){
        super(context, attrs);
        mContext = context;
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        if(isInEditMode()){
            return;
        }
        int childCount = getChildCount();
        ViewGroup viewGroup = (ViewGroup) getChildAt(/*childCount - 1*/0);
        PreferenceUtil preferenceUtil = PreferenceUtil.getInstance(mContext);
        int layoutLeft = preferenceUtil.getInt(PreferenceUtil.HORI_KEYBOARD_LAST_LEFT,0);
        int height = viewGroup.getHeight();
        int layoutRight = layoutLeft+viewGroup.getWidth();
        int layoutTop  = bottom - top - height;
        viewGroup.layout(layoutLeft,layoutTop,layoutRight,bottom);
    }
}
